<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <router-view></router-view>
    </div>
    <script src="./vue.js"></script>
    <script src="./vue-router.js"></script>
    <script>
       const demo1 = {
           template:`
           <div class='demo1'>文章{{$route.params.id}}</div>
           `
       }
       const demo2 = {
         template:`
           <div>文章{{$route.query.id}}</div>
         ` ,
         created () {
             console.log(this.$route)
         }
         
       }
        const routes = [{
            path:'/demo1/:id',
            component: demo1
        },{
            path:'/demo2',

            component:demo2
        }
        ]
        const router = new VueRouter({
            routes
        })

        const app = new Vue({
            el:'#app',
            router
        })

    </script>
</body>

</html>